package listener;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import pojo.Book;
import com.fasterxml.jackson.databind.ObjectMapper;
import dao.BookDao;
import dao.impl.BookDaoImpl;
public class MyInfoListener implements  MessageListener {
	private BookDao bookDao=new BookDaoImpl();
	public void onMessage(Message message) {
		 try {
	           TextMessage tmMessage=(TextMessage) message;
	           ObjectMapper mapper = new ObjectMapper();
	           Book book=mapper.readValue(tmMessage.getText(), Book.class);
	           bookDao.addBook(book);
	        } catch (Exception e) {
	            e.printStackTrace();
	        }
	}


}
